XLinq, XmlReader, and XmlWriter data message query sample


Windows Runtime
Data Access
Windows RT
en-US
11/25/2013

This sample demonstrates how to use the System.Xml and System.Xml.Linq (XLinq)classes and methods supported by the .NET for Windows Store apps API library. The sample opens a text file that contains an XML document, queries the XML document, and saves the results to another XML text file/

This sample covers two scenarios:

  • Querying an XML message with XLinq inside a Windows Store app. To accomplish this, the sample uses the XDocument and XElement and queries against them using LINQ.
  • Processing the XML message with XmlReader and XmlWriter inside a Windows Store app. XmlReader and XmlWriter are part of the System.Xml namespace. These classes are used to create the XDocument instance that the sample queries with LINQ and then serializes to a file, respectively.

"XLinq" refers to the use of LINQ to query XML documents using the classes (such as XDocument and XElement) and methods defined in System.Xml.Linq. These namespaces and their classes are only available to Windows Store apps using C++, C#, or Visual Basic.

Note  To run this sample you must apply for a Bing Maps key, then replace “INSERT_YOUR_BING_MAPS_KEY” with your key in the source code.

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Note  For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.

Related topics

Windows 8 app samples

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2

Build the sample

  1. Start Visual Studio 2013 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio 2013 Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

Note  To run this sample you must apply for a Bing Maps key, then replace “INSERT_YOUR_BING_MAPS_KEY” with your key in the source code.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.